package com.acwing.partition21;

import java.io.*;
import java.util.Arrays;

/**
 * @author `RKC`
 * @date 2022/3/11 14:50
 */
public class AC2069网络分析_模拟 {

    private static final int N = 10010, M = 100010;
    private static int[] h = new int[N], e = new int[M * 2], ne = new int[M * 2], w = new int[N];
    private static boolean[] st = new boolean[N];
    private static int n, m, idx = 0;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        n = Integer.parseInt(ss[0]);
        m = Integer.parseInt(ss[1]);
        Arrays.fill(h, -1);
        while (m-- > 0) {
            ss = reader.readLine().split(" ");
            int a = Integer.parseInt(ss[0]), b = Integer.parseInt(ss[1]), c = Integer.parseInt(ss[2]);
            if (a == 1) {
                add(b, c);
                add(c, b);
            } else {
                Arrays.fill(st, false);
                st[b] = true;
                dfs(b, c);
            }
        }
        for (int i = 1; i <= n; i++) writer.write(w[i] + " ");
        writer.flush();
    }

    private static void dfs(int u, int k) {
        w[u] += k;
        for (int i = h[u]; i != -1; i = ne[i]) {
            int v = e[i];
            if (st[v]) continue;
            st[v] = true;
            dfs(v, k);
        }
    }

    private static void add(int a, int b) {
        e[idx] = b;
        ne[idx] = h[a];
        h[a] = idx++;
    }
}
